3D Graphics Programming with QuickDraw 3D 1.5.4
Previous | QD3D Book | Overview | Chapter Contents | Next |
Some lights suffer attenuation; that is, a loss of intensity over distance. The application determines the degree of attenuation of a light by specifying substituends for three distinct variables in a complex term that occurs in whatever formula it uses to compute the intensity of that light at a given distance from its source. The choice of constants determines whether the light suffers attenuation and, if so, the degree to which its intensity diminishes as a function of distance. These constants are specified in a data structure of the type described here.
The attenuation factor determined by an attenuation data type is expressed by the result of replacing the variables c 0, c 1, c 2 by the values of the fields c0 , c1 , c2 in the complex term
(Here l is the location of the light source, p is the illuminated point, and dl, p is the distance from l to p .)
The initial intensity of a light is multiplied by its attenuation factor when the intensity of the light at a point is computed. Thus, if c 0 = 1 and c 1 = c 2 = 0, then the light does not suffer attenuation over distance. If c 1 = 1 and c 0 = c 2 = 0, then the intensity of the light at a point p diminishes in proportion to the distance between p and the light source, provided that that distance is at least one unit. If c 2 = 1 and c 0 = c 1 = 0, then the intensity of the light at p diminishes in proportion to the square of the distance between p and the light source, again provided that that distance is at least one unit. If c 0 = c 2 = 1 and c 1 = 0, then the intensity of the light at p diminishes in proportion to the sum of 1 and the square of the distance between p and the light source.
The attenuation factor is not clamped to a maximum value. Thus, for some choices of c 0, c 1, c 2, the intensity of a light may exceed its source intensity at distances of less than one unit, driving the RGB color values of the light toward the maximum of (1, 1, 1), or pure white.
The amount of illumination that a point illuminated by a light receives from that light also depends on several other factors. Among these factors are the diffuse and specular reflection characteristics of the surface that contains that point and the relative positions of the light source, the illuminated point, and the viewer (the camera).
A spot light specifies a cone of light emanating from a source location. Within the inner cone defined by the hot angle of a spot light, the light may suffer attenuation over distance from the light source. Within the outer section of the cone between the hot angle and the outer angle of a spot light, the light may suffer further attenuation.
Spot lights have a fall-off value that determines the manner of attenuation of the light from the edge of the cone defined by the hot angle to the edge of the cone defined by the outer angle. The direction of fall off is perpendicular to the ray from the source location through the center of the cone. The amount of additional attenuation determined by any fall-off value is the same along all rays from the location of the light source forming the same angle with the axis of the cone.
The following constants specify four fall-off values a spot light may have.
Previous | QD3D Book | Overview | Chapter Contents | Next |